home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Interapplication Communication / SuspendAppleEvent / SuspendEvent•Read Me < prev   
Encoding:
Text File  |  1992-10-26  |  2.1 KB  |  52 lines  |  [TEXT/MPS ]

  1. SuspendEvent
  2.  
  3. A simple example of suspending and resuming an AppleEvent.
  4.  
  5. What it Does....
  6.  
  7. This simple application has two document types, FRED and AL documents.
  8. When it receives an 'odoc' OpenDocuments event, it looks that the
  9. files it has been asked to open.  If it has been asked to open
  10. FRED documents, it opens them at once.  If it has been asked to
  11. open AL   documents, it suspends the event.  It waits until you
  12. click in a window before it actually opens the AL document.
  13.  
  14. A real good way to watch it work is to select all three documents (in the Finder),
  15. FredDoc1,FredDoc2, and AlDoc and select 'Open' from
  16. the Finder's FILE menu.  The two Fred documents will open, and the Al document
  17. will be suspended until you click in one of the windows.
  18.  
  19. Things to Look At...
  20.  
  21. To suspend and resume appleevents, you have got to keep the event and reply
  22. around for the event you have suspended.  
  23. ••• NOTE!!!!  Do NOT copy the Pointer that you got passed!  You have to save the
  24. acutal AEDesc structure, the DescriptorType and DataHandle!  If you just
  25. copy the pointer to that structure that you have been passed, Bad Things 
  26. (like bus errors) wil happen when you resume the event, because the AppleEVent
  27. Manager may have moved the data so the pointer you now have is not valid.
  28. So, DON'T DO
  29. AEDesc * savedEvent = eventIn;
  30. instead do...
  31. AEDesc savedEvent = *eventIn;
  32. Copy the CONTENTS, not the pointer!
  33.  
  34. Of course, if you are going to be suspending and resuming a few events,
  35. you'll need to build some kind of queuing system for yourself.
  36.  
  37. • NOTE:  Don't suspend gratuitiously.  Some AppleEvent Manager calls rely on the
  38. context of the current event to work correctly. specifically if you do something
  39. like
  40. AESuspendTheCurrentEvent(....);
  41. AEInteractWithUSer(...);
  42. AEResumeTheCurrentEvent(...);
  43. You've blown away the context that AEInteract needs to know about, and you might not 
  44. get the behaviour you want (MacApp users note:  MacApp does this, that is _wrong_
  45. and you should modify the TServerEvent class).
  46.  
  47. Please also note the beautiful icons this application uses.  Now you know
  48. why I'm a programmer.
  49.  
  50. Have a Nice Event,
  51. C.K. Haun
  52. Apple Developer Tech Support